{% macro render_field(field,show_required_flag=True) %}{#表单项#}
	{% if kwargs.get('type')=='hidden' %}
		{{ field(**kwargs)|safe }}
	{% else %}
		<div class="row">
		{% if field.type=='BooleanField' %}
			<div class="col-lg-4"></div>
			<div class="col-lg-8">{{ field(**kwargs)|safe }}{{ field.label }}</div>
		{% elif field.type=='SubmitField' %}
			<div class="col-lg-4"></div>
			<div class="col-lg-8">{{ field(**kwargs)|safe }}</div>
		{% else %}  
		  	<div class="col-lg-4">{{ field.label }}</div>
		  	<div class="col-lg-8">{{ field(**kwargs)|safe }} {% if show_required_flag and field.flags.required %} * {% endif %}</div>
		  {% if field.errors %}
		  		<div class="col-lg-4"></div>
		  		<div class="col-lg-8">
					<span class="error">*{{field.errors[0]}}</span>
				</div>
		  {% endif %}
	  {% endif %}
	  </div>
	{% endif %}
{% endmacro %}

{% macro logined_user_info() %}{#用户登录信息#}
	{% if g.user.is_authenticated %}
	  欢迎您：{{g.user.username}} | 
{#	  <a href="{{url_for('modify_pwd')}}">修改密码</a>｜#}
	  <a href="{{url_for('logout')}}" >退出登录</a>
	{% endif %}
{% endmacro %}


{% macro render_pagination(pagination, endpoint) %}
    <ul class="pagination pagination-lg">
    {% if pagination.has_prev %}
    	<li><a href="{{ url_for(endpoint, nowpage=pagination.prev_num) }}">&laquo;</a></li>
    {% else %}
    	<li class="disabled"><a href="#">&laquo;</a></li>
    {% endif %}
    
    {%- for page in pagination.iter_pages() %}
      {% if page %}
        {% if page != pagination.page %}
          <li><a href="{{ url_for(endpoint, nowpage=page) }}">{{ page }}</a></li>
        {% else %}
          <li class="active"><a href="">{{ page }}</a></li>
        {% endif %}
      {% else %}
	     <li class="disabled"><a href="">...</a></li>
      {% endif %}
    {%- endfor %}

    {% if pagination.has_next %}
    	<li><a href="{{ url_for(endpoint, nowpage=pagination.next_num) }}">&raquo;</a></li>
    {% else %}
    	<li class="disabled"><a href="#">&raquo;</a></li>
    {% endif %}
    </ul>
{% endmacro %}


